package cn.cqie.attendance.manager.controller;

import cn.cqie.attendance.common.util.Page;
import cn.cqie.attendance.common.util.PageBean;
import cn.cqie.attendance.manager.pojo.AdminStudent;
import cn.cqie.attendance.manager.pojo.AdminStudentSerch;
import cn.cqie.attendance.manager.service.AdminStudentService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @author 697
 * @date 2021/6/18 16:55
 */
@RestController
@Api(tags = "管理员端-学生信息管理模块")
@RequestMapping("/admin/student")
public class AdminStudentController {

    @Autowired
    private AdminStudentService adminStudentService;


    /**
     * 根据班级ID查询该班级下所有学生信息
     * @param classesId 班级ID
     * @param pageSize 每一页的数量
     * @param pageNum 当前页
     * @return
     */
    @GetMapping("/queryAllStudentByClassesId")
    @ApiOperation("根据班级ID查询该班级下所有学生信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "classesId", value = "班级id(1)", required = true),
            @ApiImplicitParam(name = "pageSize", value = "每一页的数量(10)", required = false),
            @ApiImplicitParam(name = "pageNum", value = "当前页(1)", required = false)})
    public PageBean<AdminStudent> queryAllStudentByClassesId(Integer classesId, Integer pageSize, Integer pageNum){
        return adminStudentService.queryAllStudentByClassesId(classesId,pageSize,pageNum);
    }


    /**
     * 查询某个班级下的学生信息，可模糊查询 组合查询
     * @param adminStudentSerch
     * @param pageSize 每一页数量
     * @param pageNum 页数
     * @return
     */
    @GetMapping("/queryAllStudentByClassesIdByCombination")
    @ApiOperation("查询某个班级下的学生信息，可模糊查询 组合查询")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "stuClass", value = "班级id(1)", required = true),
            @ApiImplicitParam(name = "direction", value = "方向(1)", required = false),
            @ApiImplicitParam(name = "email", value = "邮箱(2044691601@qq.com)", required = false),
            @ApiImplicitParam(name = "gender", value = "性别(0女1男)", required = false),
            @ApiImplicitParam(name = "identity", value = "身份证(5002291235652588)", required = false),
            @ApiImplicitParam(name = "phone", value = "手机号(13628462356)", required = false),
            @ApiImplicitParam(name = "stuName", value = "学生姓名(张三)", required = false),
            @ApiImplicitParam(name = "stuNumber", value = "学号(189000401)", required = false),
            @ApiImplicitParam(name = "pageSize", value = "每一页的数量(10)", required = false),
            @ApiImplicitParam(name = "pageNum", value = "当前页(1)", required = false)})
    public PageBean<AdminStudent> queryAllStudentByClassesIdByCombination(AdminStudentSerch adminStudentSerch, Integer pageSize, Integer pageNum){
        return adminStudentService.queryAllStudentByClassesIdByCombination(adminStudentSerch,pageSize,pageNum);
    }


    /**
     * 给某个班级新增学生
     * @param id ID
     * @param stuNumber 学号
     * @param stuName 学生姓名
     * @param identity 身份证号
     * @param gender 性别 0女 1男
     * @param email 邮箱
     * @param phone 手机号
     * @param direction 项目角色
     * @return
     */
    @PostMapping("/addStudentToClasses")
    @ApiOperation("给某个班级新增学生")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "id", value = "班级id(1)", required = true),
            @ApiImplicitParam(name = "stuNumber", value = "学号(189000401)", required = true),
            @ApiImplicitParam(name = "stuName", value = "学生姓名(张三)", required = true),
            @ApiImplicitParam(name = "identity", value = "身份证(5002291235652588)", required = true),
            @ApiImplicitParam(name = "gender", value = "性别(0女1男)", required = true),
            @ApiImplicitParam(name = "email", value = "邮箱(2044691601@qq.com)", required = true),
            @ApiImplicitParam(name = "phone", value = "手机号(13628462356)", required = true),
            @ApiImplicitParam(name = "direction", value = "项目角色(1)", required = true)})
    public Page<AdminStudent> addStudentToClasses(Integer id,String stuNumber, String stuName, String identity, String gender, String email, String phone, Integer direction){
        return adminStudentService.addStudentToClasses(id,stuNumber,stuName,identity,gender,email,phone,direction);
    }


    /**
     * 修改某个班级学生信息
     * @param classId 班级ID
     * @param stuId 学生ID
     * @param stuNumber 学号
     * @param stuName 学生姓名
     * @param identity 身份证
     * @param gender 性别 0女 1男
     * @param email 邮箱
     * @param phone 手机号
     * @param direction 方向
     * @return
     */
    @PostMapping("/updateStudentById")
    @ApiOperation("修改某个班级学生信息")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "classId", value = "班级id(1)", required = true),
            @ApiImplicitParam(name = "stuId", value = "学生id(1)", required = true),
            @ApiImplicitParam(name = "stuNumber", value = "学号(189000401)", required = true),
            @ApiImplicitParam(name = "stuName", value = "学生姓名(张三)", required = true),
            @ApiImplicitParam(name = "identity", value = "身份证(5002291235652588)", required = true),
            @ApiImplicitParam(name = "gender", value = "性别(0女1男)", required = true),
            @ApiImplicitParam(name = "email", value = "邮箱(2044691601@qq.com)", required = true),
            @ApiImplicitParam(name = "phone", value = "手机号(13628462356)", required = true),
            @ApiImplicitParam(name = "direction", value = "项目角色(1)", required = true)})
    public Page<AdminStudent> updateStudentById(Integer classId, Integer stuId, String stuNumber, String stuName, String identity, String gender, String email, String phone, Integer direction){
        return adminStudentService.updateStudentById(classId,stuId,stuNumber,stuName,identity,gender,email,phone,direction);
    }


    /**
     * 通过学生id批量删除(某个班级的)学生、支持批量删除(单独删除)
     * @param list
     * @return
     */
    @PostMapping("/deleteStudentById")
    @ApiOperation("通过学生id批量删除(某个班级的)学生、支持批量删除(单独删除)")
    public Page deleteStudentById(@RequestBody List<Integer> list){
        return adminStudentService.deleteStudentById(list);
    }


    @PostMapping("/updateGroupLeaderByGroupId")
    @ApiOperation("设置组长")
    @ApiImplicitParams({
            @ApiImplicitParam(name = "studentId", value = "学生id(1)", required = true),
            @ApiImplicitParam(name = "groupId", value = "小组id(1)", required = true)})
    public Page updateGroupLeaderByGroupId(Integer studentId,Integer groupId){
        return adminStudentService.updateGroupLeaderByGroupId(studentId,groupId);
    }


}
